<?php
session_start();
require 'libs/ControllerBase.php';
require 'libs/models/portadaModel.php';
class contactoController extends ControllerBase
{
	public function contacto(){	
		//Se crea instancia del modelo
		$model = new portadaModel();
		
		//Se obtiene el registro
		$registro = $model->getContactData();
		
		//Se obtiene la información y se le pasa a la vista
		$contacto = $registro->fetch();
		
		$data['phone']  = substr($contacto['phone_number'], 0, 3) . 
		                  " " .
		                  substr($contacto['phone_number'], 3, 2) .
		                  " " .
		                  substr($contacto['phone_number'], 5, 2) .
		                  " " .
		                  substr($contacto['phone_number'], 7, 2);	
			
		$data['url_fb'] = $contacto['facebook'];
		$data['url_tw'] = $contacto['twitter'];
		$data['mail']   = $contacto['email'];
		
		$subStringTW = explode("/", $contacto['twitter']);
 		$intMax      = count($subStringTW);
 		$data['name_tw'] = $subStringTW[$intMax - 1];
 		
 		//Se obtiene el texto que aparecerá en el formulario
 		$registro_texto = $model->getContactText();
 		
 		//Se obtiene el texto
 		$texto = $registro_texto->fetch();
 		
 		
 		//Se pasa el texto a la vista
 		$data['texto_contacto'] = $texto['content'];
		
		
		$this->view->show("contacto.php", $data);
	}
}
?>